package com.test01;

import com.test01.utils.JdbcUtils;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class TestDelete {
    public static void main(String[] args) {
        Connection connection = null;
        Statement statement = null;
        ResultSet resultSet = null;
        try {
            connection = JdbcUtils.getConnection();//获取数据库连接
            statement = connection.createStatement();
            String sql = "DELETE FROM users WHERE id=4";
            int i = statement.executeUpdate(sql); //i 表示受影响的行数
            if (i > 0) {
                System.out.println("删除成功！");
            }

        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            JdbcUtils.releaseConnection(connection,statement,resultSet);
        }
    }
}
